package cn.stylefeng.guns.modular.business.controller;


import cn.stylefeng.guns.modular.business.pojo.HeritageInfoRequest;
import cn.stylefeng.guns.modular.business.service.HeritageInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 遗产控制器
 *
 * @author zhangyaowen
 * @date 2021/11/05 15:32
 */
@RestController
@ApiResource(name = "遗产")
public class HeritageInfoController {

    @Resource
    private HeritageInfoService heritageInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "添加", path = "/heritageInfo/add")
    public ResponseData add(@RequestBody @Validated(HeritageInfoRequest.add.class) HeritageInfoRequest heritageInfoRequest) {
        heritageInfoService.add(heritageInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "删除", path = "/heritageInfo/delete")
    public ResponseData delete(@RequestBody @Validated(HeritageInfoRequest.delete.class) HeritageInfoRequest heritageInfoRequest) {
        heritageInfoService.del(heritageInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "编辑", path = "/heritageInfo/edit")
    public ResponseData edit(@RequestBody @Validated(HeritageInfoRequest.edit.class) HeritageInfoRequest heritageInfoRequest) {
        heritageInfoService.edit(heritageInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "查看详情", path = "/heritageInfo/detail")
    public ResponseData detail(@Validated(HeritageInfoRequest.detail.class) HeritageInfoRequest heritageInfoRequest) {
        return new SuccessResponseData(heritageInfoService.detail(heritageInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取列表", path = "/heritageInfo/list")
    public ResponseData list(HeritageInfoRequest heritageInfoRequest) {
        return new SuccessResponseData(heritageInfoService.findList(heritageInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "分页查询", path = "/heritageInfo/page")
    public ResponseData page(String value,String heritage,String heritageType) {
        return new SuccessResponseData(heritageInfoService.findPage(value,heritage,heritageType));
    }

    /**
     * 遗产考古分类词组
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "遗产考古分类词组", path = "/heritageInfo/heritageType")
    public ResponseData heritageType() {
        return new SuccessResponseData(heritageInfoService.heritageType());
    }


    /**
     * 获取遗产考古详细信息
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取遗产考古详细信息", path = "/heritageInfo/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(heritageInfoService.toReview(id));
    }
}